use minigrep::Config;
use std::env;
use std::process;

fn main() {
    //cargo run you poem.txt
    //CASE_INSENSITIVE=true cargo run how poem.txt
    let args: Vec<String> = env::args().collect();
    // println!("{:?}", args);

    let config = Config::new(&args).unwrap_or_else(|err| {
        //使用eprintln，不会输出到标准输出
        eprintln!("Problem parsing arguments : {}", err);
        process::exit(1);
    });
    // println!("Searching for [{}]", config.query);
    // println!("In file {}", config.filename);

    if let Err(e) = minigrep::run(config) {
        eprintln!("App error: {}", e);
        process::exit(1);
    }
}
